package chapter17.chapter17_7;

import java.util.PriorityQueue;
import java.util.Random;

/**
 * Created by Caesar on 2016/4/2.
 */
public class Test11 extends PriorityQueue<Nums> {
    public static void main(String[] args) {
        Test11 test = new Test11();
        for (int i = 0; i < 100; i++)
            test.offer(new Nums());
        while (!test.isEmpty())
            System.out.println(test.poll());
    }
}

class Nums implements Comparable<Nums> {
    private int num;

    public Nums() {
        Random random = new Random();
        num = random.nextInt(100);
    }

    @Override
    public int compareTo(Nums o) {
        return num > o.num ? 1 : (num == o.num ? 0 : -1);
    }
    @Override
    public String toString() {
        return ""+num;
    }
}
